﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<!--Head-->
<head>
    <meta charset="utf-8" />
    <title>@ViewBag.title</title>

    <meta name="description" content="login page" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="shortcut icon" href="~/assets/img/favicon.png" type="image/x-icon">

    <!--Basic Styles-->
    <link href="~/assets/css/bootstrap.min.css" rel="stylesheet" />
    <link id="bootstrap-rtl-link" href="" rel="stylesheet" />
    <link href="~/assets/css/font-awesome.min.css" rel="stylesheet" />

    <!--Fonts-->
    <link href="http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300" rel="stylesheet" type="text/css">

    <!--Beyond styles-->
    <link id="beyond-link" href="~/assets/css/beyond.min.css" rel="stylesheet" />
    <link href="~/assets/css/demo.min.css" rel="stylesheet" />
    <link href="~/assets/css/animate.min.css" rel="stylesheet" />
    <link id="skin-link" href="" rel="stylesheet" type="text/css" />

    <!--jquery-->
    <script src="~/Scripts/jquery-3.1.1.js"></script>
    <script src="~/Scripts/jquery.cookie.js"></script>
    <script src="~/Scripts/jquery.md5.js"></script>

    <!--Skin Script: Place this script in head to load scripts for skins and rtl support-->
    @*<script src="~/assets/js/skins.min.js"></script>*@

    <!--[if lte IE 8]>
        <div id="errorie"><div>您还在使用老掉牙的IE，正常使用系统前请升级您的浏览器到 IE8以上版本 <a target="_blank" href="http://windows.microsoft.com/zh-cn/internet-explorer/ie-8-worldwide-languages">点击升级</a>&nbsp;&nbsp;强烈建议您更改换浏览器：<a href="http://down.tech.sina.com.cn/content/40975.html" target="_blank">谷歌 Chrome</a></div></div>
    <![endif]-->

</head>
<!--Head Ends-->
<!--Body-->
<body>
    <div class="login-container animated fadeInDown">
        <div class="loginbox bg-white" >
            <div class="loginbox-title">登  录  框</div>
            <div class="loginbox-social">
                <div class="social-title ">用 你 的 社 交 账 户 登 录</div>
                <div class="social-buttons">
                    <a href="#" class="button-facebook">
                        <i class="social-icon fa fa-facebook"></i>
                    </a>
                    <a href="#" class="button-twitter">
                        <i class="social-icon fa fa-twitter"></i>
                    </a>
                    <a href="#" class="button-google">
                        <i class="social-icon fa fa-google-plus"></i>
                    </a>
                </div>
            </div>
            <div class="loginbox-or">
                <div class="or-line"></div>
                <div class="or">或者</div>
            </div>
            <div class="loginbox-textbox">
                <input id="txt_account" type="text" class="form-control" placeholder="电子邮箱" />
            </div>
            <div class="loginbox-textbox">
                <input id="txt_password" type="password" class="form-control" placeholder="密码" />
            </div>
            <div class="loginbox-textbox">
                <div class="form-group">
                    <input id="txt_code" class="form-control" maxlength="4" type="text" placeholder="验证码" style="width: 80px;float:left">
                    &nbsp;
                    <img id="imgcode" class="img-rounded" src="~/Login/GetAuthCode" width="80" height="33"/>
                    看不清？<a id="switchCode" href="javascript:void(0);" style="text-decoration: none;">换一张</a>    
                </div>
            </div>
            <div class="loginbox-forgot">
                <a href="">忘记密码?</a>
            </div>
            <div class="loginbox-submit">
                <button id="login_button" type="button" class="btn btn-primary btn-block"><span>登   录</span></button>
            </div>
            <div class="loginbox-signup">
                没有账号?
                <a href="register.html">点击注册</a>
            </div>
        </div>
        <div class="logobox">
            <div class="loginbox-signup">
                <div class="login_tips"></div>
            </div>
        </div>
    </div>

    <!--Basic Scripts-->
    <script src="~/assets/js/bootstrap.min.js"></script>

    <!--Beyond Scripts-->
    <script src="~/assets/js/beyond.js"></script>

    <style type="text/css">
        .tips_msg {
            height: 30px;
            line-height: 30px;
            color: red;
            margin: 0 auto;
            border-radius: 5px;
            width: 300px;
            font-size: 14px;
            text-align:center;
        }
    </style>

    <script type="text/javascript">
        (function ($) {
            $.login = {
                formMessage: function (msg) {
                    $('.login_tips').find('.tips_msg').remove();
                    $('.login_tips').append('<div class="tips_msg"><i class="fa fa-question-circle"></i>' + msg + '</div>');
                },
                loginClick: function () {
                    var $username = $("#txt_account");
                    var $password = $("#txt_password");
                    var $code = $("#txt_code");
                    if ($username.val() == "") {
                        $username.focus();
                        $.login.formMessage('请输入邮箱.');
                        return false;
                    }
                    else if ($password.val() == "") {
                        $password.focus();
                        $.login.formMessage('请输入密码.');
                        return false;
                    }
                    else if ($code.val() == "") {
                        $code.focus();
                        $.login.formMessage('请输入验证码.');
                        return false;
                    }
                    else {
                        $("#login_button").attr('disabled', 'disabled').find('span').html("loading...");
                        $.ajax({
                            url: "/Login/CheckLogin",
                            data: { username: $.trim($username.val()), password: $.trim($password.val()), code: $.trim($code.val()) },
                            type: "post",
                            dataType: "json",
                            success: function (data) {
                                if (data.state == "success") {
                                    $("#login_button").find('span').html("登录成功，正在跳转...");
                                    window.setTimeout(function () {
                                        window.location.href = "/Home/Index";
                                    }, 500);
                                } else {
                                    $("#login_button").removeAttr('disabled').find('span').html("登录");
                                    $("#switchCode").trigger("click");
                                    $code.val('');
                                    $.login.formMessage(data.message);
                                }
                            }
                        });
                    }
                },
                init: function () {
                    $("#switchCode").click(function () {
                        $("#imgcode").attr("src", "/Login/GetAuthCode?time=" + Math.random());
                    });

                    $("#login_button").click(function () {
                        $.login.loginClick();
                    });
                    document.onkeydown = function (e) {
                        if (!e) e = window.event;
                        if ((e.keyCode || e.which) == 13) {
                            document.getElementById("login_button").focus();
                            document.getElementById("login_button").click();
                        }
                    }
                    var login_error = top.$.cookie('syc_login_error');
                    if (login_error != null) {
                        switch (login_error) {
                            case "overdue":
                                $.login.formMessage("系统登录已超时,请重新登录");
                                break;
                            case "OnLine":
                                $.login.formMessage("您的帐号已在其它地方登录,请重新登录");
                                break;
                            case "-1":
                                $.login.formMessage("系统未知错误,请重新登录");
                                break;
                        }
                        top.$.cookie('syc_login_error', '', { path: "/", expires: -1 });
                    }
                }
            };
            $(function () {
                $.login.init();
            });
        })(jQuery);
    </script>
     
</body>
<!--Body Ends-->
</html>